package smartcampus.scjava.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import smartcampus.scjava.POJO.DO.Xuesheng;
import smartcampus.scjava.mapper.XueshengMapper;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;

@Service
public class XueshengService {

    @Resource
    private XueshengMapper xueshengMapper;
    //total是查询的总数  list是数据列表
    public PageInfo<Xuesheng> selectPage(Integer pageNum , Integer pageSize,Xuesheng xuesheng) {
        PageHelper.startPage(pageNum,pageSize);  //设置分页参数
        List<Xuesheng> xueshengList = xueshengMapper.selectAll(xuesheng);
        return PageInfo.of(xueshengList);

    }
    //新增
    public void add(Xuesheng xuesheng) {
        xueshengMapper.insert(xuesheng);
    }

    public void deleteById(Integer id) {
        xueshengMapper.deleteById(id);
    }

    public void updateById(Xuesheng xuesheng) {
        xueshengMapper.updateById(xuesheng);
    }

    public List<Xuesheng> findAll() {
        return xueshengMapper.findAll();
    }

    public Collection<Object> findEmployedStudents() {
        return xueshengMapper.findEmployedStudents();
    }

    public Collection<Object> findUnemployedStudents() {
        return xueshengMapper.findUnemployedStudents();
    }

    public List<String> selectAllXuehao() {
        return xueshengMapper.selectAllXuehao();
    }

    public String selectNameByXuehao(String xuehao) {
        return xueshengMapper.selectNameByXuehao(xuehao);
    }

    public int totalPage() {
        return xueshengMapper.totalPage();
    }
}
